
namespace Patterns4Net.Core
{
    using System.Collections.Generic;
    using System.Diagnostics.Contracts;
    using System.Linq;
    using Mono.Cecil;
    using Patterns4Net.Attributes.DesignPatterns;
    using Patterns4Net.Core.Patterns;
    using Patterns4Net.Attributes;

    [Immutable]
    public class PatternsLocationResult
    {
        public PatternsLocationResult(IEnumerable<TypeAndPatterns> types, IEnumerable<MethodAndPatterns> methods)
        {
            Contract.Requires(types != null);
            Contract.Requires(methods != null);
            this.Types = types.ToArray();
            this.Methods = methods;
        }

        public IEnumerable<TypeAndPatterns> Types { get; private set; }

        public IEnumerable<MethodAndPatterns> Methods { get; private set; }
    }

    [Immutable]
    public class TypeAndPatterns
    {
        public TypeAndPatterns(TypeDefinition typeDefinition, IEnumerable<IPattern> patterns)
        {
            Contract.Requires(typeDefinition != null);
            Contract.Requires(patterns != null);
            this.TypeDefinition = typeDefinition;
            this.Patterns = patterns.ToArray();
        }

        public TypeDefinition TypeDefinition { get; private set; }

        public IEnumerable<IPattern> Patterns { get; private set; }
    }

    [Immutable]
    public class MethodAndPatterns
    {
        public MethodAndPatterns(MethodDefinition methodDefinition, IEnumerable<IPattern> patterns)
        {
            Contract.Requires(methodDefinition != null);
            Contract.Requires(patterns != null);
            this.MethodDefinition = methodDefinition;
            this.Patterns = patterns.ToArray();
        }

        public MethodDefinition MethodDefinition { get; private set; }

        public IEnumerable<IPattern> Patterns { get; private set; }
    }
}
